﻿using UnityEngine;
using System.Collections;

public class BrightnessEffect : MonoBehaviour {

	public Shader curShader = null;
	public float Brightness = 1.0f;
	private Material curMaterial = null;


	public Material material {
		get {
			if (curMaterial == null) {
				curMaterial = new Material(curShader);
				curShader.hideFlags = HideFlags.HideAndDontSave;
			}
			return curMaterial;
		}
	}

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnRenderImage(RenderTexture sourceTexture, RenderTexture destTexture) {
		if (curShader != null) {
			material.SetFloat("_BrightnessAmount", Brightness);
			Graphics.Blit(sourceTexture, destTexture, material);
		}
		else {
			Graphics.Blit(sourceTexture, destTexture);
		}
	}
}
